#!/usr/bin/env python2
#coding=utf-8

import pandas as pd
import glob
import os
import sys

def merge_with_panda(files):
    extension = 'csv'
    # 这个写法不合适，很可能需要从命令行传递文件参数
    #files = [ i for i in glob.glob('*.{}'.format(extension))]
    combined_csv = pd.concat([pd.read_csv(f) for f in files])
    combined_csv.to_csv("combined_csv.csv", index=False, encoding='utf-8-sig')

def t_use_panda(path):
    files = [f for f in os.listdir(path) if os.isfile(join(path, f))]
    merge_with_panda(files)

def t_simple_merge(file1, file2, output):
    f1 = open(file1, 'r')
    f2 = open(file2, 'r')
    f = open(output, 'w')
    list1 = []
    list2 = []
    for l in f1:
        list1.append(l.strip())
    for l in f2:
        list2.append(l.strip())
    
    for i in range(len(list1)):
        l = list1[i] + ',' + list2[i].split(',')[1]
        f.write(l + '\n')

if __name__ == '__main__':
    #t_use_panda(sys.argv[1])
    t_simple_merge(sys.argv[1], sys.argv[2], sys.argv[3])